/* GUI CONVERTED from rprrmt.p (converter v1.75) Tue Aug 22 11:49:18 2000 */
/* rprrmt.p - RESOURCES REQUIREMENT MAINTENANCE                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/* All rights reserved worldwide.  This is an unpublished work.        */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 1.0     LAST MODIFIED: 05/05/85    BY: PML         */
/* REVISION: 2.0     LAST MODIFIED: 03/12/87    BY: EMB *A41*       */
/* REVISION: 2.0     LAST MODIFIED: 07/08/87    BY: EMB *A76*       */
/* REVISION: 4.0     LAST MODIFIED: 08/03/89    BY: RL  *A749*      */
/* REVISION: 7.0     LAST MODIFIED: 07/28/92    BY: ram *F814*      */
/* REVISION: 7.5     LAST MODIFIED: 10/24/94    BY: mwd *J034*          */
/* REVISION: 8.5   LAST MODIFIED: 03/05/97   BY: *G2LB* Jack Rief       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/10/00   BY: *N0K5* Arul Victoria   */
/************************************************************************/

/*J034*  * MOVED MFDTITLE.I TO TOP OF PROGRAM */
     /* DISPLAY TITLE */
/*F814*/ {mfdtitle.i "b+ "}

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 * /* ********** Begin Translatable Strings Definitions ********* */
 *
 * &SCOPED-DEFINE rprrmt_p_1 "ERROR: RESOURCE MUST EXIST.  Please re-enter."
 * /* MaxLen: Comment: */
 *
 * /* ********** End Translatable Strings Definitions ********* */
 *N0K5* ------------------- END   DELETE ----------------------- */

     define variable start like rq_start.
     define buffer rqmstr for rq_mstr.
     define variable desc1 like pt_desc1.
     define variable rsdesc like rs_desc.
     define variable del-yn like mfc_logical.

     /* DISPLAY SELECTION FORM */
     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
rq_part        colon 25
        desc1          no-label
        rq_site        colon 25
        rq_rsc         colon 25
        rsdesc         no-label
        rq_start       colon 25
        skip(1)
        rq_end         colon 25 skip(1)
        rq_qty         colon 25
        rq_lead        colon 25
        rq_lt_off      colon 25
      SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

     /* DISPLAY */
     view frame a.
     repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


        prompt-for
           rq_part
           rq_site
           rq_rsc
/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 * /*F814      ***   REMOVE THIS validate AFTER CORRECTING DB IN 7.3   *** */
 * /*F814*/      validate(can-find(rs_mstr where rs_site = input rq_site
 * /*F814*/      and rs_rsc = rq_rsc),
 * /*F814*/      {&rprrmt_p_1})
 *N0K5* ------------------- END   DELETE ----------------------- */
           rq_start
        editing:

           /* SET GLOBAL PART VARIABLE */
           global_part = input rq_part.

           if frame-field = "rq_part"
           or frame-field = "rq_site"
           or frame-field = "rq_rsc" then do:
          /* FIND NEXT/PREVIOUS RECORD */
          {mfnp.i rq_mstr rq_part rq_part rq_rsc rq_rsc rq_part}

          if recno <> ? then do:
             desc1 = "".
             find pt_mstr where pt_part = rq_part
             no-lock no-wait no-error.
             if available pt_mstr then desc1 = pt_desc1.
             rsdesc = "".
             find rs_mstr where rs_rsc = rq_rsc
             and rs_site = rq_site
             no-lock no-error.
             if available rs_mstr then rsdesc = rs_desc.
             display
            rq_part
            desc1
            rq_site
            rq_rsc
            rsdesc
            rq_start
            rq_end
            rq_qty
            rq_lead
            rq_lt_off.
          end.
           end.
           else do:
          /* FIND NEXT/PREVIOUS RECORD */
          {mfnp06.i rq_mstr rq_rsc
          "rq_part = input rq_part and rq_site = input rq_site"
          rq_rsc "input rq_rsc" rq_start "input rq_start"}

          if recno <> ? then do:
             desc1 = "".
             find pt_mstr where pt_part = rq_part
             no-lock no-wait no-error.
             if available pt_mstr then desc1 = pt_desc1.
             rsdesc = "".
             find rs_mstr where rs_rsc = rq_rsc
             and rs_site = rq_site
             no-lock no-error.
             if available rs_mstr then rsdesc = rs_desc.
             display
            rq_part
            desc1
            rq_site
            rq_rsc
            rsdesc
            rq_start
            rq_end
            rq_qty
            rq_lead
            rq_lt_off.
          end.
           end.
        end.  /* PROMPT-FOR...EDITING */

/*J034*/       {gprun.i ""gpsiver.p""
           "(input (input rq_site), input ?, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

/*J034*/       if return_int = 0 then do:
/*J034*/          {mfmsg.i 725 3} /*USER DOES NOT HAVE ACCESS TO THIS SITE */
/*J034*/          next-prompt rq_site.
/*J034*/          undo, retry.
/*J034*/       end.

/*N0K5* ------------------- BEGIN ADD ----------------------- */
          if frame-field = "rq_rsc" then
          do:
             if not can-find(rs_mstr where rs_site = rq_site
                             and rs_rsc = rq_rsc) then
             do:
                {mfmsg.i 3591 3}  /* RESOURCE MUST EXIST */
                next-prompt rq_rsc with frame a.
                undo, retry.
             end.

          end.
/*N0K5* ------------------- END   ADD ----------------------- */

        desc1 = "".
        find pt_mstr where pt_part = input rq_part no-lock no-error.
        if available pt_mstr then desc1 = pt_desc1.
        rsdesc = "".
        find rs_mstr where rs_rsc = input rq_rsc
        and rs_site = input rq_site
        no-lock no-error.
        if available rs_mstr then rsdesc = rs_desc.

        /* ADD/MOD/DELETE  */
        del-yn = no.
        find first rq_mstr using rq_rsc and rq_part
        and rq_site
        and rq_start no-error.
        if not available rq_mstr then do:
           {mfmsg.i 1 1}
           create rq_mstr.
           assign rq_part rq_site rq_rsc rq_start.

           if available pt_mstr then rq_part = pt_part.
           if available rs_mstr then rq_rsc = rs_rsc.
        end.

        recno = recid(rq_mstr).

        ststatus = stline[2].
        status input ststatus.

        display rq_part desc1 rq_site rq_rsc rsdesc
        rq_end rq_qty rq_lead rq_lt_off.

        setloop:
        do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

/*G2LB*        set rq_end rq_qty rq_lead rq_lt_off editing: */
/*G2LB*/       update rq_end rq_qty rq_lead rq_lt_off editing:

          readkey.

          /* DELETE */
          if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
          then do:
             del-yn = yes.
             {mfmsg01.i 11 1 del-yn}
             if del-yn then leave.
          end.
          else apply lastkey.
           end.
           if del-yn then do:
          delete rq_mstr.
          clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
           end.
           else do:
          /* CHECK FOR NO OVERLAPPING INTERVALS */
          for each rqmstr where rqmstr.rq_rsc = input rq_mstr.rq_rsc
             and rqmstr.rq_part = input rq_mstr.rq_part
             and rqmstr.rq_site = input rq_mstr.rq_site
             no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


             if recid(rq_mstr) <> recid(rqmstr)
             and (((rqmstr.rq_start <= rq_mstr.rq_end
            or rq_mstr.rq_end = ?)
             and (rqmstr.rq_end >= rq_mstr.rq_start
            or rq_mstr.rq_start = ?))
             or (rqmstr.rq_start = ?
            and rqmstr.rq_end >= rq_mstr.rq_start)
             or (rqmstr.rq_end = ?
            and rqmstr.rq_start <= rq_mstr.rq_end)
             or (rqmstr.rq_start = ? and rqmstr.rq_end = ?)) then do:

            {mfmsg.i 26 3} /* Overlapping interval */
            undo setloop, retry.
             end.

          end.
/*GUI*/ if global-beam-me-up then undo, leave.

           end.
        end.
/*GUI*/ if global-beam-me-up then undo, leave.

     end.
/*GUI*/ if global-beam-me-up then undo, leave.


     status input.
